home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / System / ReqToolsLib / Source / reqtools / misc.asm < prev    next >
Encoding:
Assembly Source File  |  2001-07-02  |  7.2 KB  |  407 lines

  1.  
  2.     SECTION "dofmt",CODE
  3.  
  4.     INCLUDE "exec/types.i"
  5.     INCLUDE "exec/funcdef.i"
  6.     INCLUDE "exec/exec_lib.i"
  7.     INCLUDE "lvo/utility_lib.i"
  8.     INCLUDE "intuition/intuitionbase.i"
  9. ;    INCLUDE "lvo/intuition_lib.i"
  10.     INCLUDE "lvo/graphics_lib.i"
  11.  
  12.     INCLUDE "utility/hooks.i"
  13.  
  14.     INCLUDE "libraries/gadtools.i"
  15.  
  16.     INCLUDE "intuition/intuition.i"
  17.     INCLUDE "lvo/intuition_lib.i"
  18.     INCLUDE "intuition/classes.i"
  19.     INCLUDE "intuition/classusr.i"
  20.     INCLUDE "intuition/imageclass.i"
  21.  
  22.     INCLUDE "libraries/reqtools.i"
  23.     INCLUDE "lvo/reqtools_lib.i"
  24.  
  25.     XDEF _DofmtCount
  26.     XDEF _Dofmt
  27.     XDEF _DofmtArgs
  28.     XDEF _FillBarTable
  29.     XDEF _FillNewLineTable
  30.     XDEF _LoopReqHandler
  31.     XDEF _CallHook
  32.     XDEF _StrCat
  33.     XDEF _MakeColVal
  34.     XDEF @SpreadColors
  35.     XDEF @DoWaitPointer
  36.     XDEF @DoLockWindow
  37.     XDEF @SetWinTitleFlash
  38.  
  39.     XREF _ReqToolsBase
  40.     XREF _IntuitionBase
  41.     XREF _GfxBase
  42.     XREF _UtilityBase
  43.  
  44.     XREF __UCXD33
  45.  
  46. * void __regargs SetWinTitleFlash (struct Window *win, char *str)
  47. *                                  A0                  A1
  48. @SetWinTitleFlash:
  49.     movem.l    a2/a6,-(a7)
  50.     move.l    _IntuitionBase(a4),a6
  51.     movem.l    a0/a1,-(a7)
  52.     move.l    wd_WScreen(a0),a0
  53.     jsr    _LVODisplayBeep(a6)
  54.     movem.l    (a7)+,a0/a1
  55.     moveq    #-1,d0
  56.     move.l    d0,a2
  57.     jsr    _LVOSetWindowTitles(a6)
  58.     movem.l    (a7)+,a2/a6
  59.     rts
  60.  
  61. * void __regargs DoWaitPointer (struct Window *win, int doit, int setpointer)
  62. *                               A0                  D0        D1
  63. @DoWaitPointer:
  64.     tst.l    d0
  65.     beq.b    exitwaitpointer
  66.  
  67.     move.l    a0,d0
  68.     beq.b    exitwaitpointer
  69.  
  70.     move.l    a6,-(a7)
  71.     tst.l    d1
  72.     beq.b    clearpointer
  73.  
  74. setpointer:
  75.     move.l    _ReqToolsBase(a4),a6
  76.     jsr    _LVOrtSetWaitPointer(a6)
  77.     bra.b    endwaitpointer
  78.  
  79. clearpointer:
  80.     move.l    _IntuitionBase(a4),a6
  81.     jsr    _LVOClearPointer(a6)
  82. endwaitpointer:
  83.     move.l    (a7)+,a6
  84. exitwaitpointer:
  85.     rts
  86.  
  87. * APTR __regargs DoLockWindow (struct Window *win, int doit, APTR lock, int lockit)
  88. *                              A0                  D0        A1         D1
  89. @DoLockWindow:
  90.     tst.l    d0
  91.     beq.b    exitlockwin
  92.  
  93.     move.l    a0,d0
  94.     beq.b    exitlockwin
  95.  
  96.     move.l    a6,-(a7)
  97.     move.l    _ReqToolsBase(a4),a6
  98.     tst.l    d1
  99.     beq.b    unlockwin
  100.  
  101.     jsr    _LVOrtLockWindow(a6)
  102.     bra.b    endlockwin
  103.  
  104. unlockwin:
  105.     jsr    _LVOrtUnlockWindow(a6)
  106. endlockwin:
  107.     move.l    (a7)+,a6
  108. exitlockwin:
  109.     rts
  110.  
  111. * void __regargs SpreadColors (GlobData *glob, int from, int to, long *rgb2)
  112. *                              A0              D0        D1      A1
  113.  
  114. cols        equ        12
  115. vp        equ        (cols+3*4)
  116. redbits        equ        (vp+4)
  117. greenbits    equ        (redbits+4)
  118. bluebits    equ        (greenbits+4)
  119.  
  120. * _LVOSetRGB32    equ    -$354
  121.  
  122. _MakeColVal:
  123.     move.l    d1,-(a7)
  124.     moveq    #32,d1
  125.     sub.l    d4,d1
  126.     lsl.l    d1,d0
  127.     move.l    d0,d1            ; shift color value completely to the left
  128. .nextshift:
  129.     lsr.l    d4,d1
  130.     beq.b    endmakecol
  131.  
  132.     or.l    d1,d0            ; shift right and or
  133.     bra.b    .nextshift
  134.  
  135. endmakecol:
  136.     move.l    (a7)+,d1
  137.     rts
  138.  
  139. @SpreadColors:
  140.     movem.l    d2-d7/a2-a6,-(a7)
  141.     lea    -24(a7),a7
  142.     lea    12(a7),a2        ; a2 -> rgb[3]
  143.     move.l    a7,a3            ; a3 -> rgbstep[3]
  144.     moveq    #1,d4            ; d4 = colstep = 1
  145.     move.l    a0,a5
  146.     move.l    d0,d5
  147.     move.l    d1,d6
  148.     move.l    d6,d2
  149.     sub.l    d5,d2            ; d2 = steps
  150.     beq    nospread
  151.  
  152.     bpl.b    posstep
  153.  
  154.     moveq    #-1,d4
  155.     neg.l    d2
  156. posstep:
  157.     moveq    #2,d3
  158. spreadloop:
  159.     lsl.l    #2,d3
  160.     move.l    cols(a5,d3.w),d7
  161.     move.l    0(a1,d3.w),d0
  162.     sub.l    d7,d0
  163.     swap    d0
  164.     clr.w    d0
  165.     move.l    d2,d1
  166.     move.l    _UtilityBase(a4),a6
  167.     jsr    _LVOSDivMod32(a6)    ; ((rgb2[i] - rgb[i]) << 16) / steps
  168.     move.l    d0,0(a3,d3.w)
  169.     swap    d7
  170.     move.l    d7,0(a2,d3.w)        ; rgb[i] = glob->cols[i] << 16
  171.     lsr.l    #2,d3
  172.     dbf    d3,spreadloop
  173.     move.l    #$8000,d7        ; d7 = .5 (16 bits fixed point)
  174. spreadloop2:
  175.     move.l    vp(a5),a0
  176.     move.l    (a2),d1
  177.     add.l    d7,d1
  178.     swap    d1
  179.     move.l    4(a2),d2
  180.     add.l    d7,d2
  181.     swap    d2
  182.     move.l    8(a2),d3
  183.     add.l    d7,d3
  184.     swap    d3
  185.     move.l    _GfxBase(a4),a6
  186.     moveq    #39,d0
  187.     cmp.w    LIB_VERSION(a6),d0
  188.     bls.s    .okkick39
  189.  
  190.     move.l    d5,d0
  191.     jsr    _LVOSetRGB4(a6)
  192.     bra.b    .cont
  193.  
  194. .okkick39:
  195.     move.l    d4,-(a7)
  196.     move.l    redbits(a5),d4
  197.     move.l    d1,d0
  198.     bsr    _MakeColVal
  199.     move.l    d0,d1
  200.     move.l    greenbits(a5),d4
  201.     move.l    d2,d0
  202.     bsr    _MakeColVal
  203.     move.l    d0,d2
  204.     move.l    bluebits(a5),d4
  205.     move.l    d3,d0
  206.     bsr    _MakeColVal
  207.     move.l    d0,d3
  208.     move.l    vp(a5),a0
  209.     move.l    d5,d0
  210.     jsr    _LVOSetRGB32(a6)
  211.     move.l    (a7)+,d4
  212. .cont:
  213.     move.l    (a3),d0
  214.     add.l    d0,(a2)
  215.     move.l    4(a3),d0
  216.     add.l    d0,4(a2)
  217.     move.l    8(a3),d0
  218.     add.l    d0,8(a2)
  219.     add.l    d4,d5
  220.     cmp.l    d5,d6
  221.     bne.b    spreadloop2
  222. nospread:
  223.     lea    24(a7),a7
  224.     movem.l    (a7)+,d2-d7/a2-a6
  225.     rts
  226.  
  227. ;_LVORawDoFmt    equ    -$20a
  228.  
  229. * if you want to count the newlines and the number of chars call DoFmt with
  230. * buff == NULL and with ptr pointing to an array of 2 longs. array[0] will
  231. * hold the number of lines, array[1] the number of chars.
  232. * Initialize array[1] and array[0] to 1!
  233.  
  234. * void DofmtCount (char *fmt, APTR args, ULONG *ptr, int mode);
  235. *                  A0         A1         A3          D0
  236.  
  237. * void Dofmt (char *buff, char *fmt, APTR args);
  238. *             A3          A0         A1
  239.  
  240. * void __stdargs DofmtArgs (char *buff, char *fmt,...);
  241. *
  242.  
  243. _DofmtArgs:
  244.     movem.l    a2/a3/a6,-(a7)
  245.     move.l    4+12(a7),a3
  246.     move.l    8+12(a7),a0
  247.     lea    12+12(a7),a1
  248.     bra.b    dofmtargs
  249.  
  250. _DofmtCount:
  251.     movem.l a2/a3/a6,-(a7)
  252.     moveq    #1,d1
  253.     move.l d1,(a3)+
  254.     move.l d1,(a3)
  255.     tst.l    d0
  256.     bne.b    seperatorbar
  257.  
  258.     lea    CountNewLinesAndChars(PC),a2
  259.     bra.b    dofmt
  260.  
  261. seperatorbar:
  262.     lea    CountBarsAndChars(PC),a2
  263.     bra.b    dofmt
  264.  
  265. _Dofmt:
  266.     movem.l    a2/a3/a6,-(a7)
  267. dofmtargs:
  268.     lea    PutCharInBuff(PC),a2
  269. dofmt:
  270.     move.l    ($4).w,a6
  271.     jsr    _LVORawDoFmt(a6)
  272.     movem.l    (a7)+,a2/a3/a6
  273.     rts
  274.  
  275. PutCharInBuff:
  276.     move.b    d0,(a3)+
  277.     rts
  278.  
  279. CountBarsAndChars:
  280.     cmp.b    #'|',d0
  281.     bne.b    nobar
  282.  
  283.     bra.b    isbar
  284.  
  285. CountNewLinesAndChars:
  286.     cmp.b    #10,d0
  287.     bne.b    nonewline
  288.  
  289. isbar:
  290.     addq.l #1,-4(a3)
  291. nonewline:
  292. nobar:
  293.     addq.l #1,(a3)
  294.     rts
  295.  
  296. * void FillBarTable (char **table, char *buff)
  297. *                    A1            A0
  298.  
  299. * void FillNewLineTable (char **table, char *buff)
  300. *                        A1            A0
  301.  
  302. _FillBarTable:
  303.     move.b    #'|',d1
  304.     bra.b    filltable
  305. _FillNewLineTable:
  306.     move.b    #$0a,d1
  307. filltable:
  308.     move.l    a0,(a1)+
  309. loopnl:
  310.     move.b    (a0)+,d0
  311.     beq.b    done
  312.  
  313.     cmp.b    d1,d0
  314.     bne.b    loopnl
  315.  
  316.     clr.b    -1(a0)
  317.     move.l    a0,(a1)+
  318.     bra.b    loopnl
  319. done:
  320.     rts
  321.  
  322. * ULONG __asm LoopReqHandler (register __a1 struct rtHandlerInfo *)
  323. * D0                                        A1
  324.  
  325.     XREF    rtReqHandlerA
  326.  
  327. _LoopReqHandler:
  328.     move.l    a2,-(a7)
  329. loophandler:
  330.     moveq    #0,d0
  331.     tst.l    rthi_DoNotWait(a1)
  332.     bne.b    nowait
  333.  
  334.     movem.l    a1/a6,-(a7)
  335.     move.l    rthi_WaitMask(a1),d0
  336.     move.l    ($4).w,a6
  337.     jsr    _LVOWait(a6)
  338.     movem.l    (a7)+,a1/a6
  339.     ; d0 holds sigs
  340. nowait:
  341.     sub.l    a0,a0
  342.     sub.l    a2,a2
  343.     move.l    a1,-(a7)
  344.     jsr    rtReqHandlerA(PC)
  345.     move.l    (a7)+,a1
  346.     cmp.l    #CALL_HANDLER,d0
  347.     beq.b    loophandler
  348.  
  349.     move.l    (a7)+,a2
  350.     rts
  351.  
  352. * ULONG __stdargs CallHook (struct Hook *, APTR,...);
  353.  
  354. _CallHook:
  355.     movem.l    a2/a3,-(a7)
  356.     move.l    4+8(a7),a0
  357.     move.l    8+8(a7),a2
  358.     lea    12+8(a7),a1
  359.     move.l    h_Entry(a0),a3
  360.     jsr    (a3)
  361.     movem.l    (a7)+,a2/a3
  362.     rts
  363.  
  364. * void StrCat (UBYTE *, UBYTE *);
  365. *        a0    a1
  366. _StrCat:
  367.     tst.b    (a0)+
  368.     bne.b    _StrCat
  369.  
  370.     subq.l    #1,a0
  371. catloop:
  372.     move.b    (a1)+,(a0)+
  373.     bne.b    catloop
  374.     rts
  375.  
  376.     IFD    DICE_HACK
  377.  
  378.     XREF    _IntuitionBase
  379.  
  380.     XREF    _MyGetString
  381.     XDEF    _GetString
  382.  
  383. * ULONG __saveds GetString (
  384. *    register __a1 UBYTE *stringbuff,        /* str in case of rtEZRequestA */
  385. *    register __d0 int maxlen,            /* args in case of rtEZRequestA */
  386. *    register __a2 char *title,            /* gadfmt in case of rtEZRequestA */
  387. *    register __d1 ULONG checksum,
  388. *    register __d2 ULONG *value,
  389. *    register __d3 int mode,
  390. *    register __d4 struct rtReqInfo *reqinfo,
  391. *    register __a0 struct TagItem *taglist)
  392. *
  393.  
  394. _GetString:
  395.     move.l    a0,-(sp)
  396.     movem.l    d1-d4,-(sp)
  397.     move.l    a2,-(sp)
  398.     move.l    d0,-(sp)
  399.     move.l    a1,-(sp)
  400.     bsr    _MyGetString
  401.     lea    8*4(sp),sp
  402.     rts
  403.  
  404.     ENDC
  405.  
  406.     END
  407.